import React from "react";
import { useState } from "react";
import { Select, Input, Space } from "antd";
export default function Search({show}) {
  let [typeObj, setTypeObj] = useState("username");
  const { Search } = Input;
  const { Option } = Select;
  function handleChange(value) {
    setTypeObj(value);

    console.log(`selected ${value}`);
  }
  const onSearch = value => {
    show({type:typeObj, value,current:1})
    console.log("搜索框值",value);
  }
  return (
    <div style={{ display: "flex" }}>
      <Select
        defaultValue="username"
        style={{ width: 120 }}
        onChange={handleChange}
      >
        <Option value="username">用户名</Option>
        <Option value="nickname">昵称</Option>
        <Option value="address">地址</Option>
      </Select>
      <Space direction="vertical">
        <Search
          placeholder="请输入搜索内容！"
          onSearch={onSearch}
          style={{ width: 200 }}
        />
      </Space>
    </div>
  );
}
